package com.gzu.live.controller;

import com.gzu.live.pojo.Live;
import com.gzu.live.pojo.LiveUser;
import com.gzu.live.service.LiveUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

//用户控制类（观看者）
@RestController
@RequestMapping("/liveUser")
public class LiveUserController {
    @Autowired
    private LiveUserService liveUserService;
    //获取直播用户记录表所有信息
    @GetMapping("/findAll")
    public List<LiveUser> findLiveUserList(){
        return liveUserService.findLiveUserList();
    }
    //根据直播编号获取直播间信息
    @GetMapping("/findLive/{userId}")
    public Live findLiveById(@PathVariable("userId") int userId){
        return liveUserService.findLiveById(userId);
    }
    //根据用户id获取用户信息
    @GetMapping("/findLiveUser/{userId}")
    public List<LiveUser> findLiveUserById(@PathVariable("userId") int userId){
        return  liveUserService.findLiveUserById(userId);
    }
    //统计用户记录表总人数
    @GetMapping("/countViews")
    public int countViewsById(){
        return liveUserService.countViewsById();
    }

}
